package com.leexuan.ordersystem.forms;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class LoginForm extends ActionForm {

	private String username = null;
	private String password = null;

	public LoginForm() {
		super();
	}

	public void reset(ActionMapping mapping, HttpServletRequest request) {

		this.username = null;
		this.password = null;

	}

	public String getUsername() {
		return this.username;
	}

	public String getPassword() {
		return this.password;
	}

	public void setUsername(String Username) {
		this.username = Username;
	}

	public void setPassword(String Password) {
		this.password = Password;
	}

	public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {

		ActionErrors errors = new ActionErrors();

		if ((username == null) || (username.length() < 1)) {
			// errors.add("username", new
			// ActionMessage("error.login.username.required"));
			errors.add("username", new ActionMessage("error.login.username.required"));
		}

		if ((password == null) || (password.length() < 1)) {
			errors.add("password", new ActionMessage("error.login.password.required"));
		}

		return errors;
	}

}
